package io.openkunlun.javadsl.client;

import io.openkunlun.javadsl.v1.DaprProtos;
import lombok.Builder;
import lombok.Data;

import java.util.List;
import java.util.Map;

@Data
@Builder
public final class GetBulkStateAction implements DaprAction<GetBulkStateResult> {

    private String storeName;
    private List<String> keys;
    private Integer parallelism;
    private Map<String, String> metadata;

    /**
     * @param daprClient
     * @return
     */
    @Override
    public GetBulkStateResult invoke(DaprClient daprClient) throws Exception {
        DaprProtos.GetBulkStateResponse response = daprClient.getBulkState(DaprProtos.GetBulkStateRequest
                .newBuilder()
                .setStoreName(storeName)
                .addAllKeys(keys)
                .setParallelism(parallelism)
                .putAllMetadata(metadata)
                .build());
        return GetBulkStateResult.builder()
                .items(response.getItemsList())
                .build();
    }
}
